package cn.zktr.Personnel.controllers.ouyangpeng;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import cn.zktr.Personnel.model.pojos.PerIntention;
import cn.zktr.Personnel.model.pojos.PerPmsPot;
import cn.zktr.Personnel.model.pojos.PerRetDem;
import cn.zktr.Personnel.model.pojos.PerRetRse;
import cn.zktr.Personnel.model.pojos.PerRetWen;
import cn.zktr.Personnel.model.service.ouyangpeng.RetDemService;
import cn.zktr.Personnel.model.service.ouyangpeng.RetRseService;


@Controller
public class RetDemController {
	@Autowired
	private RetDemService retdemservice;
	@Autowired
	private RetRseService retrseservice;
	
	//初步审核
    @RequestMapping("oyp/recruit-chushenhe")
    public void demo8() {
    	
    }
    @RequestMapping("chubuyuan")
    @ResponseBody
    public Map<String,Object> dnshenqing(int page,int rows){
    	Map<String,Object> map = new HashMap<>();
		map.put("total",retrseservice.selectchububiao().size());
		Page<Object> p=PageHelper.startPage(page,rows);
		List<PerRetRse> findAll=retrseservice.selectchububiao();
		//页内容
		map.put("rows",findAll);
		return map;
    }
    //初步审核通过
    @PostMapping("shenhe_rsezt")
    @ResponseBody
    private void selectchutg(HttpSession session,Integer demcbtongguo_dem,Integer demcbtongguo_rse) {
	    session.setAttribute("demid", retdemservice.updatedemid(demcbtongguo_dem));
		retdemservice.selectchubutg(demcbtongguo_dem);
	    retdemservice.tgchubujianli(demcbtongguo_rse);
    }
    //初步审核不通过
    @PostMapping("shenhebu_rsezt")
    @ResponseBody
    private void selectchubutg(HttpSession session,Integer demcbbutongguo_dem,Integer demcbbutongguo_rse) {
	    session.setAttribute("demid", retdemservice.updatedemid(demcbbutongguo_dem));
		retdemservice.selectchububutg(demcbbutongguo_dem);
		retdemservice.butgchubujianli(demcbbutongguo_rse);
    }
    //发起考试--->意向表添加数据
    @PostMapping("shenhe_qukaoshi")
    @ResponseBody
    public void yixiangbzx(int qukaoshi_dem,int qukaoshi_rse,int qukaoshi_pot) {
    	System.err.println("----"+qukaoshi_dem+"---"+qukaoshi_rse+"---"+qukaoshi_pot);
    	PerRetDem dem=new PerRetDem();
    	dem.setDemid(qukaoshi_dem);
    	PerRetRse rse=new PerRetRse();//简历表
    	rse.setRseid(qukaoshi_rse);
    	PerPmsPot pot=new PerPmsPot();//职位
    	pot.setPotid(qukaoshi_pot);
    	
    	PerIntention inten=new PerIntention();
    	inten.setPerRetDem(dem);
    	inten.setPerRetRse(rse);
    	inten.setPerPmsPot(pot);
    	inten.setIonrem("招聘");
    	inten.setIonstat(1);

    	retdemservice.yixiangxz(inten);
    }
    //发起考试时修改初步审核和简历状态
    @PostMapping("kaoshi_zhuantai")
    @ResponseBody
    private void kaoshichubujl(Integer kaoshizt_dem,Integer kaoshizt_rse) {
		retdemservice.kaoschububutg(kaoshizt_dem);
		retdemservice.kschubujianli(kaoshizt_rse);
    }
    //发起考试时新增笔试记录
    @PostMapping("kaoshi_bishijilu")
    @ResponseBody
    public void chububishi(int ksbishijilu_dem) {
    	PerRetDem dem=new PerRetDem();
    	dem.setDemid(ksbishijilu_dem);
    	
    	PerRetWen wen=new PerRetWen();
    	wen.setPerRetDem(dem);

    	retdemservice.kaosbihsi(wen);
    }
}
